#include<bits/stdc++.h>
using namespace std;

const int N=2*1e5+5;

int n;
int a[N],b[N],bz[N];

int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	b[1]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i>1 and a[i]==a[i-1]) b[i]=b[i-1];
		if(i>1 and a[i]!=a[i-1]) b[i]=i; 
	} 
	int sum=0;
	while(1){
		if(sum>n) break;
		for(int i=1;i<=n;i++){
			if(!bz[b[i]]){
				printf("%d ",b[i]);
				bz[b[i]]=1;
			}
		}
		printf("\n");
		sum++;
		for(int i=1;i<=n;i++){
			if(!bz[i]) b[i]=b[b[i-1]]+1;
			for(int j=i-1;j>=1;j--){
				if(!bz[j]){
					if(a[i]==a[j]) b[i]=b[j];
					break;
				}
			}
		} 
		int mid=0,p=0;
		for(int i=1;i<=n;i++) if(!bz[i]) mid=b[i];
		for(int i=1;i<=n;i++){
			if(!bz[i] and mid!=b[i]){
				p=1;
				break;
			} 
		}
		if(!p or !mid) break;
	}
	for(int i=1;i<=n;i++)
			if(!bz[i] and b[i]){
				printf("%d\n",i);
			} 
	return 0;
} 
